# _*_ coding: utf-8 _*_
import threading

from odoo import models, fields, api


class SaleOrder(models.Model):
    _inherit = "sale.order"

    price_confirmed = fields.Boolean(string="Price Confirmed")

    @api.multi
    def toggle_price_confirmed(self):
        for record in self:
            record.price_confirmed = not record.price_confirmed

    def action_rerun_procure_calculation_sale_sync(self):
        self.ensure_one()
        threaded_calculation = threading.Thread(target=self.order_line.procure_calculation_sale,
                                                args=(self.procurement_group_id.procurement_ids.ids,))
        threaded_calculation.start()
        return True
